﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using RobotBattle2.Runtime;
using RobotBattle2.Scripting;

namespace RobotBattle2.Interpreter {
	public class CallStackFrame : VariableScope, ICallStackFrame {
		public CallStackFrame(MethodDeclaration method, ICallStackFrame parentFrame)
			: this(method, parentFrame, null) { }

		public CallStackFrame(MethodDeclaration method, ICallStackFrame parentFrame, IVariableScope parentScope)
			: base(parentScope) {
			this.Method = method;
			this.ParentFrame = parentFrame;
			Trace.Push(new TraceFrame(method.Statements, this));
		}

		public MethodDeclaration Method { get; private set; }
		public ICallStackFrame ParentFrame { get; private set; }
		public object ReturnValue { get; set; }

		public Stack<TraceFrame> Trace { get { return m_Trace; } }
		private Stack<TraceFrame> m_Trace = new Stack<TraceFrame>();
	}
}
